from fabric import Connection, task

host_ip = '123.56.1.174'
user_name = 'root'
password = '@LiJing0106..'


@task
def deploy(c):
    with Connection(host_ip, user_name, connect_kwargs={'password': password}) as c:
        c.run("rm -rf dist && mkdir -p ~/client/dist")
        c.put("./dist", "~/client/dist")
        c.put("./docker/Dockerfile", "~/client/Dockerfile")
        c.put("./docker/nginx.conf", "~/client/nginx.conf")
        c.run("cd ~/client && docker build -t registry.cn-beijing.aliyuncs.com/qianyucc/qimages:v1.0.2 .", pty=True)
        c.run(
            "docker push registry.cn-beijing.aliyuncs.com/qianyucc/qimages:v1.0.2", pty=True)
